<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: false, b: false, c: true, d: false, e: false, f: false }"
      ></navigationHeTong>
      <div v-if="zhiShow == 1" class="boxsty zhiBiao">
        <!-- <div class="flex justifyContentSpaceBetween">
          <div class="tabletext">合同审核</div>
        </div> -->
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="合同名称">
                <el-input
                  v-model="dataForm.contractName"
                  placeholder="合同名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人姓名">
                <el-input
                  v-model="dataForm.shouyueName"
                  placeholder="受约人"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人岗位">
                <el-input
                  v-model="dataForm.shouyueZhiwu"
                  placeholder="受约人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="受约人职级">
                <el-input
                  v-model="dataForm.ryZjmc"
                  placeholder="受约人职级"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="发约人姓名">
                <el-input
                  v-model="dataForm.fayueName"
                  placeholder="发约人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList()"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>

        <div class="avue-crud">
          <div style="border-top: 1px solid #b0bde2">
            <div class="mt10">
              业绩合同
              <span>
                <el-radio v-model="radio" label="1">个人</el-radio>
                <el-radio v-model="radio" label="2">机构</el-radio>
              </span>
              <span
                style="margin-left: 160px"
                v-if="permissions.hetongrenwu_hetonghtxxdjb_scope"
              >
                数据范围
                <el-radio-group v-model="radioTwo">
                  <el-radio
                    v-for="(item, index) in radioTwoList"
                    :label="item.value"
                    :key="index"
                    >{{ item.name }}</el-radio
                  >
                </el-radio-group>
              </span>
              <div style="float: right">
                <el-button plain type="primary" @click="mingxi"
                  >文本模式</el-button
                >
                <el-button plain type="primary" @click="nidingHz"
                  >指标汇总</el-button
                >
                <el-button plain type="primary" @click="plsh('同意', '列表')"
                  >同意</el-button
                >
                <el-button plain type="primary" @click="plsh('驳回', '列表')"
                  >驳回</el-button
                >
              </div>
            </div>
          </div>
          <el-table
            ref="table"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            border
            v-if="rednermsg"
            @row-click="unfoldBtn"
            v-loading="dataListLoading"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="80"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="contractName"
              header-align="center"
              align="center"
              min-width="200"
              show-overflow-tooltip
              label="合同名称"
            >
              <template slot-scope="scope">
                <span
                  @click="checkDetails(scope.row,scope.$index)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.contractName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 2"
              prop="jigouName"
              header-align="center"
              show-overflow-tooltip
              align="center"
              label="机构名称"
            >
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueCode"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人编号"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueCode.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueCode).slice(
                    0,
                    2
                  )"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueCode).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueCode).length > 2 && index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueName"
              header-align="center"
              align="center"
              min-width="120"
              label="受约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.shouyueName).slice(
                    0,
                    2
                  )"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueName).length > 2 && index === 0
                    "
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1"
              prop="shouyueDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="受约人单位"
              show-overflow-tooltip
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueDeptName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(
                    scope.row.shouyueDeptName
                  ).slice(0, 2)"
                  :key="index"
                >
                  <el-badge
                    :value="cutout(scope.row.shouyueDeptName).length"
                    :max="9"
                    v-if="
                      cutout(scope.row.shouyueDeptName).length > 2 &&
                      index === 0
                    "
                    class="itembadge"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 1"
              prop="shouyueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人岗位"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人职级">
                  <span
                    ><i
                      @click="switchBtn(2)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人岗位</span
                  >
                </el-tooltip>
              </template>
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.shouyueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="item in cutout(scope.row.shouyueZhiwu).slice(0, 2)"
                >
                  <span>{{ validatenull(item) ? "-" : item | ellipsis }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              v-if="radio == 1 && shows == 2"
              prop="ryZjmc"
              header-align="center"
              align="center"
              min-width="180"
              label="受约人职级"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至受约人岗位">
                  <span
                    ><i
                      @click="switchBtn(1)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >受约人职级</span
                  >
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueName"
              header-align="center"
              align="center"
              min-width="120"
              label="发约人姓名"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueName.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="(item, index) in cutout(scope.row.fayueName).slice(
                    0,
                    2
                  )"
                >
                  <el-badge
                    :value="cutout(scope.row.fayueName).length"
                    :max="9"
                    v-if="cutout(scope.row.fayueName).length > 2 && index === 0"
                    style="margin-top: 10px; margin-right: 0px"
                  >
                    <span>{{ item }}</span>
                  </el-badge>
                  <span v-else>{{ item }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="fayueZhiwu"
              header-align="center"
              align="center"
              min-width="180"
              label="发约人岗位"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.rowshows == false">
                  <span v-for="item in scope.row.fayueZhiwu.split(',')"
                    >{{ item }}<br
                  /></span>
                </div>
                <div
                  v-if="scope.row.rowshows == true"
                  v-for="item in cutout(scope.row.fayueZhiwu).slice(0, 2)"
                >
                  <span>{{
                    (validatenull(item) ? "-" : item) | ellipsis
                  }}</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column
              prop="indiNumbers"
              header-align="center"
              align="center"
              min-width="100"
              label="指标数量"
            >
            </el-table-column>
            <el-table-column
              prop="contractAuditStatus"
              header-align="center"
              align="center"
              min-width="100"
              label="合同状态"
            >
              <template slot-scope="scope">
                <span v-html="cutout2(scope.row.contractAuditStatus)" />
              </template>
            </el-table-column>
            <el-table-column
              prop="textreviewDatetime"
              header-align="center"
              align="center"
              min-width="100"
              show-overflow-tooltip
              label="接收时间"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>

      <TianBaoTable
        v-if="zhiShow == 3"
        ref="tianbaotable"
        :dataListHT="dataListHT"
        :tianBaoTable="tianBaoTable"
        :ids="ids"
        :radio="radio"
        @fnBackOldPage="fnBackOldPage"
      ></TianBaoTable>
      <zhibiaoForm
        ref="zhibiaoRef"
        v-if="zhiShow == 2"
        :zhibiaoForm="zhibiaoForm"
        v-on:zhibiaoChild="zhibiaoChild"
        :hetongId="hetongId"
        :contractName="contractName"
        :htqdorwbsh="htqdorwbsh"
      ></zhibiaoForm>
      <genzongForm
        v-if="genzongFormData.dialogVisible"
        :genzongFormData="genzongFormData"
      ></genzongForm>
      <!--进入页面就展示的详情-->
      <el-dialog
        v-if="dataList.length > 0"
        :title="carouselForm.contractName"
        :visible.sync="centerDialogVisible && dataList.length > 0"
        width="70%"
        :show-close="false"
        center
      >
        <div>
          <table border="1" class="carouselBox" style="width: 100%">
            <tbody>
              <tr>
                <td>发约人姓名:</td>
                <td>职务:</td>
                <td>受约人姓名:</td>
                <td>职务:</td>
                <td>合同有效期起:</td>
                <td>合同有效期止:</td>
                <td>签订日期:</td>
              </tr>
              <tr>
                <td>{{ carouselForm.fayueName }}</td>
                <td>{{ carouselForm.fayueZhiwu }}</td>
                <td>
                  <div v-if="carouselForm.rowshows == false">
                    <span v-for="item in carouselForm.shouyueName.split(',')"
                      >{{ item }}<br
                    /></span>
                  </div>
                  <div
                    v-if="carouselForm.rowshows == true"
                    v-for="(item, index) in cutout(
                      carouselForm.shouyueName
                    ).slice(0, 2)"
                    :key="index"
                  >
                    <el-badge
                      :value="cutout(carouselForm.shouyueName).length"
                      :max="9"
                      v-if="
                        cutout(carouselForm.shouyueName).length > 2 &&
                        index === 0
                      "
                      class="itembadge"
                    >
                      <span>{{ item }}</span>
                    </el-badge>
                    <span v-else>{{ item }}</span>
                  </div>
                </td>
                <td>{{ carouselForm.shouyueZhiwu }}</td>
                <td>{{ carouselForm.htYxqq }}</td>
                <td>{{ carouselForm.htYxqz }}</td>
                <td>{{ carouselForm.signDate }}</td>
              </tr>
            </tbody>
          </table>
          <div class="btns2" @click="prevBtn"><i class="el-icon-arrow-left" style="color:#fff"></i></div>
          <el-carousel
            style="margin-top: 20px"
            indicator-position="none"
            ref="carouselRef"
            direction="vertical"
            :autoplay="false"
          >
            <el-carousel-item
              v-for="item in dataList"
              style="overflow-y: auto"
              :key="item.id"
            >
              <el-table
                :data="carouselData"
                border
                style="width: 100%"
                v-loading="carouselLoading"
              >
                <el-table-column
                  prop="zhibiaoType"
                  label="指标类别"
                  min-width="90"
                  header-align="center"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="zhibiaoName"
                  label="关键业绩指标"
                  min-width="120"
                  show-overflow-tooltip
                  header-align="center"
                  align="center"
                >
                </el-table-column>

                <el-table-column
                  prop="weight"
                  label="权重(%)"
                  min-width="110"
                  header-align="center"
                  align="center"
                >
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.weight }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="unit"
                  label="单位"
                  min-width="80"
                  header-align="center"
                  align="center"
                >
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.unit }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="targetValue"
                  label="目标值"
                  min-width="150"
                  header-align="center"
                  align="center"
                >
                  <template slot-scope="scope">
                    <span>
                      {{ scope.row.targetValue }}
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  header-align="center"
                  align="center"
                  label="完成值"
                ></el-table-column>

                <el-table-column
                  prop="dataProviderId"
                  label="数据提供部门/人"
                  min-width="180"
                  header-align="center"
                  align="center"
                >
                  <template slot-scope="scope">
                    <div>
                      <span v-if="scope.row.tgLx == '2'">{{
                        scope.row.targetUserName
                      }}</span>
                      <span v-else
                        >{{
                        scope.row.dataProvider
                      }}</span
                      >
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-carousel-item>
          </el-carousel>
          <div class="btns" @click="nextBtn"><i class="el-icon-arrow-right" style="color:#fff"></i></div>
          <div style="text-align: right">
            第{{ carouselIndex + 1 }}页/共{{ dataList.length }}页
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button plain type="primary" @click="plsh('同意', '详情')"
            >同意</el-button
          >
          <el-button plain type="primary" @click="plsh('驳回', '详情')"
            >驳回</el-button
          >
          <el-button plain type="primary" @click="centerDialogVisible = false"
            >列表模式</el-button
          >
        </span>
      </el-dialog>
    </basic-container>
  </div>
</template>

<script>
import {
  fetchList,
  delObj,
  radioTwoList,
} from "@/api/hetongrenwu/hetonghtxxdjb";
import { mapGetters } from "vuex";
import zhibiaoForm from "@/views/hetongrenwu/components/zhibiao-form.vue";
import genzongForm from "@/views/hetongrenwu/components/genzong-form.vue";
import { pageForWb } from "@/api/hetongrenwu/hetongyeji/hetongnd.js";
import {
  updateplshByid,
  updateFaYueState,
} from "@/api/hetongrenwu/hetongyeji/hetongnd";
import { validatenull } from "@/util/validate";
import TianBaoTable from "@/views/hetongrenwu/components/htndhuizong-table";
import {
  getListByzbnd,
  getFormula,
  getDataProvider,
} from "@/api/hetongrenwu/hetongyeji/hetongzb";
export default {
  components: {
    zhibiaoForm,
    genzongForm,
    TianBaoTable,
  },

  data() {
    return {
      dataForm: {
        key: "",
      },
      tianBaoTable: {},
      ids: [],
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false,
      radio: "1",
      radioTwo: "-1",
      zhiShow: 1,
      zhibiaoForm: {},
      genzongFormData: {},
      searchadvanced: true,
      searchheight: "0",
      htdataList: {},
      treeOrgData: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
      iswenben: 1,
      selectedTreeData: [],
      fdata: {},
      contractAuditStatus: 5,
      zbvisible: false,
      hetongId: Number,
      rowid: Number,
      htqdorwbsh: Number,
      radioTwoList: radioTwoList,
      contractName: "",
      ryZjmc: "",
      outcome: "",
      shows: 1,
      rednermsg: true,
      centerDialogVisible: false,
      carouselIndex: 0,
      carouselData: [],
      carouselLoading: false,
      typeList: [
        { name: "手工填报", value: "0" },
        { name: "自动获取", value: "1" },
      ],
      formulaOptions: [],
      providerList: [],
      carouselForm: {},
      indexs: 0,
    };
  },
  filters: {
    ellipsis(value) {
      if (!value) return "";
      if (value.length > 8) {
        return value.slice(0, 8) + "...";
      }
      return value;
    },
  },
  created() {
    let params = this.$route.query;
    if (!validatenull(params)) {
      this.radioTwo = params.radioTwo;
    }
    this.getDataList();
    this.getXiaLa();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  watch: {
    radio(value) {
      if (value) {
        this.dataList = [];
        this.getDataList();
      }
    },
    radioTwo(value) {
      if (value) {
        this.getDataList();
      }
    },
  },
  methods: {
    mingxi() {
      if (this.dataList == null || this.dataList.length == 0) {
        this.$message.warning("没有数据!");
        return;
      }
      this.getCarouseldata(this.dataList[0]);
      this.carouselForm = this.dataList[0];
      this.centerDialogVisible = true;
      this.indexs = 0;
    },
    getCarouseldata(row) {
      this.carouselLoading = true;
      var params = {
        htId: row.id,
        str: 1,
      };
      getListByzbnd(params).then((res) => {
        this.carouselData = res.data.data;
        this.$forceUpdate();
        this.carouselLoading = false;
      });
    },
    getXiaLa() {
      getFormula().then((res) => {
        this.formulaOptions = res.data.data;
      });
      getDataProvider().then((res) => {
        if (res.data.data) {
          this.providerList = res.data.data;
          this.dataListLoading = false;
        }
      });
    },
    auditStatusFormater(row, column) {
      const auditStatus = row.auditStatus;
      if (auditStatus == 0) {
        return "未提报";
      } else if (auditStatus == 1) {
        return "填报中";
      } else if (auditStatus == 2) {
        return "审核中";
      } else if (auditStatus == 3) {
        return "已经审核";
      } else if (auditStatus == 4) {
        return "审核驳回";
      } else if (auditStatus == 5) {
        return "结果填报中";
      } else if (auditStatus == 6) {
        return "结果填报完成";
      } else if (auditStatus == 7) {
        return "填报审核驳回";
      }
    },

    unfoldBtn(row) {
      row.rowshows = !row.rowshows;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
    getDataList() {
      this.dataListLoading = true;
      this.centerDialogVisible = false;
      pageForWb(
        // isbenbu: this.radioTwo,
        Object.assign({
          type: this.radio,
          fayueName: this.dataForm.fayueName,
          fayueZhiwu: this.dataForm.fayueZhiwu,
          shouyueZhiwu: this.dataForm.shouyueZhiwu,
          quotaauditStatus: this.dataForm.quotaauditStatus,
          contractAuditStatus: this.contractAuditStatus,
          shouyueName: this.dataForm.shouyueName,
          current: this.pageIndex,
          size: this.pageSize,
          pageType: "htqdsh",
          ryZjmc: this.dataForm.ryZjmc,
          contractName: this.dataForm.contractName,
        })
      )
        .then((response) => {
          this.dataList = response.data.data.records || [];
          this.totalPage = response.data.data.total;

          if (this.dataList.length > 0) {
            this.getCarouseldata(this.dataList[0]);
            this.carouselForm = this.dataList[0];
          }

          this.dataList.forEach((ele) => {
            ele.rowshows = true;
          });
          this.dataListLoading = false;
        })
        .catch((res) => {
          this.dataListLoading = false;
        });
    },
    cutout2(cellValue) {
      if (cellValue == 0) {
        return "创建中";
      }
      if (cellValue == 1) {
        return "指标填报中";
      }
      if (cellValue == 2) {
        return "汇总中";
      }
      if (cellValue == 3) {
        return "汇总完成";
      }
      if (cellValue == 4) {
        return "文本审核中";
      }
      if (cellValue == 5) {
        return "文本审核退回";
      }
      if (cellValue == 6) {
        return "文本审核通过";
      }
      if (cellValue == 7) {
        return "受约人审核中";
      }
      if (cellValue == 67) {
        return "受约人驳回";
      }
      if (cellValue == 78) {
        return "绩效考核办公室审核中";
      }
      if (cellValue == 8) {
        return "发约人审核中";
      }
      if (cellValue == 9) {
        return "签订完成";
      }
      if (cellValue == 10) {
        return "已归档";
      }
      if (cellValue == 11) {
        return "填报中";
      }
      if (cellValue == 111) {
        return "填报审核驳回";
      }
      if (cellValue == 12) {
        return "填报审核中";
      }
      if (cellValue == 13) {
        return "汇总完成";
      }
      if (cellValue == 14) {
        return "领导审核中";
      }
      if (cellValue == 15) {
        return "领导审核完成";
      }
      if (cellValue == 16) {
        return "已结束";
      }
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //合同跟踪

    tracking(row) {
      this.rowid = row.id;
      //console.log(this.rowid)
      this.genzongFormData = {
        dialogVisible: true,
        rowid: row.id,
      };
    },
    //查看
    checkDetails(row,index) {
      this.carouselIndex = index;
      this.indexs = index;
      this.getCarouseldata(row);
      this.carouselForm = row;
      this.centerDialogVisible = true;
    },
    nextBtn(){
      this.indexs++;
      if (this.indexs == this.totalPage) {
        this.indexs = 0;
      }
      this.carouselIndex = this.indexs;
      this.dataList.forEach((item, n) => {
        if (this.indexs == n) {
          this.getCarouseldata(item);
          this.carouselForm = item;
        }
      });
    },
    prevBtn(){
      this.indexs--;
      if (this.indexs==0) {
        this.indexs = this.totalPage;
      }
      if (this.indexs== -1) {
        this.indexs = this.totalPage-1;
      }
      if (this.indexs== this.totalPage) {
        this.indexs = 0;
      }
      this.carouselIndex = this.indexs;
      this.dataList.forEach((item, n) => {
        if (this.indexs == n) {
          this.getCarouseldata(item);
          this.carouselForm = item;
        }
      });
    },
    plsh(text, type) {
      var data,
        data1,
        data2 = [];
      if (type == "列表") {
        data1 = this.$refs.table.selection;
        data = data1;
      } else {
        data2.push(this.carouselForm);
        data = data2;
      }
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请至少选择一个合同！");
        return;
      }
      var ids = [];
      for (var i = 0; i < data.length; i++) {
        ids.push(data[i].id);
      }

      if (text == "同意") {
        this.agreeBtn(text, data);
      } else {
        this.rejectedBtn(text, data);
      }
    },
    // 通过
    agreeBtn(text, data) {
      var params2 = {
        rows: data,
        outcome: "通过",
      };

      this.submit(params2, text);
    },
    // 驳回
    rejectedBtn(text, data) {
      var params2 = {
        rows: data,
        outcome: "驳回",
      };
      // var data = this.$refs.table.selection;
      for (var i = 0; i < data.length; i++) {
        if (data[i].contractAuditStatus != 7) {
          this.$message.warning("选择的数据不是受约人审核，无法驳回");
          return;
        }
      }
      this.submit(params2, text);
    },
    submit(e, text) {
      updateplshByid(e).then((res) => {
        if (res.data.data == "批量审核成功") {
          updateFaYueState(e).then((res) => {
            this.$message.closeAll();
            this.$message.success(text + "成功");
            this.getDataList();
          });
        } else {
          this.$message.closeAll();
          this.$message.success(text + "成功");
          this.getDataList();
        }
      });
    },
    //子集信息
    zhibiaoChild(zhibiaoChild) {
      if (zhibiaoChild) {
        this.zhiShow = 1;
        this.getDataList();
      }
    },

    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id);
      });
    },
    // 删除
    deleteHandle(id) {
      this.$confirm("是否确认删除ID为" + id, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          return delObj(id);
        })
        .then((data) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
        });
    },
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    nidingHz() {
      if (this.$refs.table.selection.length < 1) {
        this.$message.closeAll();
        this.$message.error("请至少选中一条合同");
        return;
      }
      if (this.multipleSelection != undefined) {
        var ids = this.multipleSelection.map((item) => {
          return item.htId;
        });
        this.ids = ids;
      } else {
        var ids = this.$refs.table.selection.map((item) => {
          return item.id;
        });
        this.ids = ids;
      }
      this.zhiShow = 3;
      this.dataListHT = this.$refs.table.selection;
      var taskIds = "";
      this.$refs.table.selection.forEach((item) => {
        taskIds = taskIds + item.taskId + ",";
      });
      this.tianBaoTable = {
        lastPage: "htsh",
        taskIds: taskIds,
      };
      this.$nextTick(() => {
        this.$refs.tianbaotable.editLock();
      });
    },
    fnBackOldPage(data) {
      this.zhiShow = 1;
      this.ids = [];
      this.multipleSelection = undefined;
      this.getDataList();
    },
    handleSelectionChange(rows) {
      this.multipleSelection = rows;
    },
    //切换显示受约人职务和受约人职级
    switchBtn(e) {
      this.shows = e;
      this.rednermsg = false;
      this.$nextTick(() => {
        this.rednermsg = true;
      });
    },
  },
};
</script>
<style>
.carouselBox td {
  padding-left: 10px;
  line-height: 40px;
}
.el-dialog__title {
  font-size: 24px !important;
}
</style>
